package com.bgs.eat.commodity.controller;

import com.bgs.eat.commodity.entity.CommodityTypeEntity;
import com.bgs.eat.commodity.service.CommodityService;
import com.bgs.eat.commodity.service.CommodityTypeService;
import com.bgs.eat.config.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CommodityTypeController
 * @Description TODO
 * @Author lzy
 * @Date 2022/10/19 14:08
 **/
@RestController
@RequestMapping("/commodityType")
@CrossOrigin
public class CommodityTypeController {

    @Autowired
    CommodityTypeService commodityTyepService;

    /**
    * @Description 校验 商品类别是否含有 商品信息（门户商家版）
    * @Author lzy
    * @Date 2022/10/25 11:27
    * @Return com.bgs.eat.config.CommonResult
    * @param id
    */
    @GetMapping("/checkTypeHaveCommodity")
    public CommonResult checkTypeHaveCommodity(Integer id) {
        return commodityTyepService.checkTypeHaveCommodity(id);
    }

    /**
    * @Description 删除商品类别（门户商家版）
    * @Author lzy
    * @Date 2022/10/20 9:24
    * @Return com.bgs.eat.config.CommonResult
    * @param id
    */
    @DeleteMapping("/deleteCommodityType")
    public CommonResult deleteCommodityType (@RequestBody Integer id) {
        return commodityTyepService.deleteCommodityType(id);
    }

    /**
    * @Description 修改商品类型（门户商家版）
    * @Author lzy
    * @Date 2022/10/20 9:20
    * @Return com.bgs.eat.config.CommonResult
    * @param commodityTypeEntity
    */
    @PutMapping("/editCommodityType")
    public CommonResult editCommodityType(@RequestBody CommodityTypeEntity commodityTypeEntity) {
        return commodityTyepService.editCommodityType(commodityTypeEntity);
    }

    /**
    * @Description 新增 商品类别（门户商家版）
    * @Author lzy
    * @Date 2022/10/19 14:15
    * @Return com.bgs.eat.config.CommonResult
    * @param commodityTypeEntity
    */
    @PostMapping("/saveCommodityType")
    public CommonResult saveCommodityType(@RequestBody CommodityTypeEntity commodityTypeEntity) {
        return commodityTyepService.saveCommodityType(commodityTypeEntity);
    }

    /**
    * @Description 根据店铺id获取当前 商品分类列表信息（门户商家版）
    * @Author lzy
    * @Date 2022/10/19 15:17
    * @Return com.bgs.eat.config.CommonResult
    * @param shopId
    */
    @GetMapping("/getCommodityTypeList")
    public CommonResult getCommodityTypeList(Integer shopId) {
        return commodityTyepService.getCommodityTypeList(shopId);
    }

}
